<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%     
	String path = request.getContextPath();     
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";     
%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>修改系统用户</title>
    <base href="<%=basePath%>"/>
    <link rel="stylesheet" type="text/css" href="css/common.css" />
    <link type="text/css" href="js/mcdropdown/css/jquery.mcdropdown.css" rel="stylesheet" media="all" />
    <script type="text/javascript" src="js/mcdropdown/lib/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="js/jquery.form.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="js/mcdropdown/lib/jquery.mcdropdown.js"></script>
    <script type="text/javascript" src="js/mcdropdown/lib/jquery.bgiframe.js"></script>
    <style type="text/css">
  		fieldset,legend,form,table,tr,td,textarea{margin:0;padding:0}
  		form label {font-weight:bold;}
    	table{margin:10px 10px};
  		td{line-height: 40px;}
		input[type="text"]{width:250px;}
		input[type="password"]{width:250px;}
		input[type="textarea"]{width:250px;}   		
    </style>
    
	<script type="text/javascript">
	  $(document).ready(function(){
	        var options = {dataType: 'json', beforeSubmit: beforeSubmit, success: process};
	        $.ajaxSetup ({ cache:false,async: false });
			$("#deptNo").mcDropdown("#categorymenu",{ dropShadow: false, targetColumnSize: 1, lineHeight:30, allowParentSelect:true});
	        $("#userForm").submit(function(){
	            $(this).ajaxSubmit(options);
	            return false;
	        });
	  });
	  
	  function beforeSubmit() {
			if(isEmpty($("#cnname").val())) { alert("别名不能为空！"); return false; }
			if(!validateSize($("#cnname").val(), 2, 32)) { alert("别名不符合规格！"); return false; }   
			
			if(!isEmpty($("#email").val()) && !isEmail($("#email").val())) { alert("Email不符合规格！"); return false; }
			
			return true;
	  }
	  
	  function process(responseJson) {
	        if(responseJson.code == 0) {
	            $('#error_label').text("错误信息：" + responseJson.message);
	            $("#p_error").show();
	            return;
	        }
	        var qs = $("#qs").val();
	        location.href = "<%=basePath%>comprehensive/contact/list.do?" + qs;
	  }
	</script>    
  </head>
  
  <body>
  <div style="width: 1208px;">
  <div>
    <fieldset>
      <legend>修改系统用户：</legend>
      <form id="userForm" method="post" action="comprehensive/contact/update.do">
      	<input type="hidden" name="id" value="${user.id}" />
      	<input type="hidden" name="enname" value="${user.enname}" />
      	<input type="hidden" name="password" value="${user.password}" />
      	<input type="hidden" name="status" value="${user.status}" />
      	<input type="hidden" name="createTime" value="${user.createTime}" />
      	<input type="hidden" name="cnname" value="${user.cnname}" />
      	<input type="hidden" name="province" value="${user.province}" />
        <input id="qs" name="qs" type="hidden" value="${qs}"/>
      	<p id = "p_error" style = "margin:10px 10px;">
      	    <label id="error_label" style="color:red;"></label>
      	</p>
        <table>
          
          <tr>
            <td><label for="enname">英文名称：</label></td>
            <td>
            	<input type="text" name="enname" id="enname" value="${user.enname }" disabled="disabled" />
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            	<label for="enname">只能由字母、数字、下划线组成，字母开始，4～32位 </label>
            </td>
          </tr>         
          <tr>
            <td><label for="cnname">别名：</label></td>
            <td>
            	<input type="text" name="cnname" id="cnname" value="${user.cnname }" disabled="disabled"/>
            	<font color="red">&nbsp;*&nbsp;&nbsp;</font>
            	<label for="cnname">可以是中文，2～32位</label>
            </td>
          </tr> 
             <tr>
           <td><label for="pNo">所属部门：</label></td>
              <td >
               <input type="text" name="deptNo" id="deptNo" value ="${user.deptNo}" defaultValue="${user.deptNo}"/>
               <ul id="categorymenu" class="mcdropdown_menu" >
			        <c:forEach items="${treeList}" var="tree" varStatus="status">
			            ${tree}
			        </c:forEach>
		       </ul>  	
            </td>              
          </tr>          
          
          <tr>
            <td><label for="mobile">手机号码：</label></td>
            <td>
            	<input type="text" name="mobile" id="mobile" value="${user.mobile }" />
            </td>
          </tr>
          <tr>
            <td><label for="phone">固定电话：</label></td>
            <td>
            	<input type="text" name="phone" id="phone" value="${user.phone }" />
            </td>
          </tr>
          <tr>
            <td><label for="email">Email：</label></td>
            <td>
            	<input type="text" name="email" id="email" value="${user.email }" />
            </td>
          </tr>  
           <tr>
            <td valign="top"><label for="remark">描述：</label></td>
            <td valign="top"><textarea name="remark" id="remark" cols="40" rows="3"><c:out value="${user.remark }"/></textarea></td>
          </tr>                   
          <tr>
            <td></td>
            <td>
            	<input type="submit" id="btn_update" value="提交" style="width:80px;" />
            	<input type="button" id="btn_back" value="返回" onclick="history.back();" style="width:80px;" />
            </td>
          </tr>
        </table>
      </form>
    </fieldset>
  </div>    
  </div>
  </body>
</html>